package com.zatech.cgnci.project.vo;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zatech.cgnci.project.base.enums.ClaimAmountTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@ApiModel("分入结算详情VO")
public class CgnciClaimSettlementVO implements Serializable {

    @ApiModelProperty("结算ID")
    private Long settlementId;

    @ApiModelProperty("结算号")
    private String settlementNo;

    @ApiModelProperty("结算序号")
    private Integer settlementSeq;

    @ApiModelProperty("案件号")
    private String caseNo;

    @ApiModelProperty("保单号")
    private String policyNo;

    @ApiModelProperty("项目名称")
    private String projectName;

    @ApiModelProperty("结算类型(PREPAYMENT-预付结算 FINAL-结案结算)")
    private String settlementType;

    @ApiModelProperty("汇率约定方式(BY_VALUE-按数值 BY_DATE-按日期)")
    private String rateType;

    @ApiModelProperty("汇率日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
    private Date rateDate;

    @ApiModelProperty("汇率")
    private BigDecimal rate;

    @ApiModelProperty("任���号")
    private String taskNo;

    @ApiModelProperty("任务状态")
    private String taskStatus;

    @ApiModelProperty("备注")
    private String remarks;

    @ApiModelProperty("公估费")
    private BigDecimal estimationAmount;

    @ApiModelProperty("摊赔金额")
    private BigDecimal compensationAmount;

    @ApiModelProperty("总计金额")
    private BigDecimal totalAmount;

    @ApiModelProperty("最新审核意见")
    private String latestAuditOpinion;

    @ApiModelProperty("分入结算列表")
    private List<ReinsurerVO> intoSettlementList;
    @ApiModelProperty("转分摊回-再保人列表")
    private List<ReinsurerVO> spreadBackSettlementList;

    @ApiModelProperty("扩展信息")
    private Map<String, Object> extra;

    @ApiModelProperty(value = "结算汇总信息", hidden = true)
    private List<SettlementSummaryVO> summaries;

    @Data
    public static class ReinsurerVO implements Serializable {
        @ApiModelProperty("再保人ID")
        private Long reinsurerId;
        @ApiModelProperty("再保人类型(CEDING-分出人 ACCEPTOR-接受人)")
        private String reinsurerType;

        @ApiModelProperty("再保人名称")
        private String reinsurerName;

        @ApiModelProperty("再保人code")
        private String reinsurerRef;

        @ApiModelProperty("唯一健")
        private String reinsurerRowKey;

//        @ApiModelProperty("层号")
//        private String layerNo;
//
//        @ApiModelProperty("层名称")
//        private String layerName;

        @ApiModelProperty("结算币种")
        private String settlementCurrency;

        @ApiModelProperty("原始币种")
        private String originalCurrency;

        @ApiModelProperty("合计结算金额（结算币种）")
        private BigDecimal totalSettlementAmount;

        @ApiModelProperty("合计结算金额（原始币种）")
        private BigDecimal totalSettlementAmountOriginal;

        @ApiModelProperty("再保人汇率")
        @NotNull(message = "再保人汇率不能为空")
        @DecimalMin(value = "0", message = "再保人汇率不能为负数")
        private BigDecimal reinsurerRate;

        @ApiModelProperty("结算明细")
        private List<DetailVO> details;
    }

    @Data
    public static class DetailVO implements Serializable {

        @ApiModelProperty("明细ID")
        private Long detailId;

        @ApiModelProperty("明细类型(INWARD-分入结算 RECOVERY-转分摊回)")
        private String detailType;

        @ApiModelProperty("险种")
        private String riskType;

        @ApiModelProperty("标的名称")
        private String subjectName;

        @ApiModelProperty("层号")
        private String layerNo;

        @ApiModelProperty("层名称")
        private String layerName;

        @ApiModelProperty("金额类型:1-赔款；2-费用")
        /**
         * @see ClaimAmountTypeEnum
         */
        private String amountType;
        @ApiModelProperty("结算币种")
        @NotNull(message = "结算币种不能为空")
        private String settlementCurrency;
        @ApiModelProperty("结算金额(结算币种)")
        @NotNull(message = "结算金额不能为空")
        @DecimalMin(value = "0", message = "结算金额不能为负数")
        private BigDecimal settlementAmount;

        @ApiModelProperty("原始币种")
        @NotNull(message = "原始币种不能为空")
        private String originalCurrency;

        @ApiModelProperty("结算金额（原始币种）")
        @NotNull(message = "结算金额（原始币种）不能为空")
        @DecimalMin(value = "0", message = "结算金额不能为负数")
        private BigDecimal settlementAmountOriginal;

        @ApiModelProperty("承接比例")
        private BigDecimal shareRatio;

        @ApiModelProperty("分出比例")
        private BigDecimal cededRatio;
    }

    @Data
    public static class SettlementSummaryVO {
        @ApiModelProperty("审批状态")
        private String approvalStatus;  // APPROVED-已批准 UNAPPROVED-未批准 TOTAL-合计

        @ApiModelProperty("结算金额(结算币种)")
        private BigDecimal settlementAmount;

        @ApiModelProperty("摊回金额(结算币种)")
        private BigDecimal recoveryAmount;

        @ApiModelProperty("自留金额(结算币种)")
        private BigDecimal retainAmount;
    }
} 